package com.yneusoft.manage.cacheMap;

import com.yneusoft.dao.entity.DepartmentState;
import com.yneusoft.dao.entity.StaffState;
import com.yneusoft.dao.mapper.DepartmentStateMapper;
import com.yneusoft.dao.mapper.StaffStateMapper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * 项目启动后自动加载数据库固定表数据
 */
@Component
public class InitMap {
    @Resource
    DepartmentStateMapper departmentState;

    @Resource
    StaffStateMapper staffStateMapper;
    @PostConstruct
    public void initMap(){
        System.out.println("加载----》");
        List<DepartmentState> list=  departmentState.selectList(null);
        DepartmentState.dataList=list;
        for (int i = 0; i < list.size() ; i++) {
            DepartmentState.dataMap.put(i, list.get(i));
        }
    }

    @PostConstruct
    public void initMap1(){
        System.out.println("加载1----》");
        List<StaffState> list=  staffStateMapper.selectList(null);
        StaffState.dataList=list;
        for (int i = 0; i < list.size() ; i++) {
            StaffState.dataMap.put(i, list.get(i));
        }
    }
}
